1. Field of the Invention
The present invention relates to a processing system for processing shared data by multi-threads, such as a processing system using object oriented database system.
2. Description of the Background Art
The recent operating system is equipped with a function for executing a program by processing with multiple threads (multi-threading) in order to utilize the shared memory type multi-processor system effectively. In the multi-threading, a plurality of threads can be executed in parallel by sharing the virtual space of the process. In switching the threads, there is no need to switch the virtual space, and only the minimum context switching is required. For this reason, it is possible to improve the performance of the parallel processing by the multi-processor system.
However, the multi-threading has a drawback in that the programming becomes rather complicated. This is because the virtual space is to be shared among the threads so that it is necessary to program the exclusive control explicitly whenever the shared data is involved.
Even in the single thread program, the exclusive control can be a problem when the data mapped to the virtual space is to be shared among the processes, as in a case of the object-oriented database system. In the object-oriented database system, the data in the secondary memory can be mapped into the virtual space and manipulated just like the ordinary data. Here, the data mapped from the secondary memory into the virtual space have a possibility of being shared by a plurality of processes, so that the exclusive control using the lock is necessary at a time of reading or updating these data. In the transaction processing, if this lock is not set up correctly, the inconsistent data can be produced in the secondary memory, and the bug of one program can affect the other programs as well.
In order to resolve this problem of the exclusive control, an automatic locking scheme has been developed for the single thread program, which utilizes the idea of single level storage. In this scheme, the set up of the lock is made by detecting the access in violation to the page protection of the MMU (memory management unit). Namely, a page having data mapped from the secondary memory is set to be in the access prohibited mode initially, such that the access exception of the MMU occurs when this data is read for the first time. Then, in the resulting exception processing, the shared lock for reading is obtained from the database management system which manages the secondary memory, and then the page protection mode is changed to the reading permitted mode. As a result, the access exception does not occur in the subsequent accesses for reading and the reading operations can be carried out as usual. Similarly, the exception occurs when this data is updated for the first time, in which case the exclusive lock for updating is obtained from the database management system in the resulting exception processing and then the page protection mode is changed to the writing permitted mode, such that the exception does not occur in the subsequent accesses for updating and the writing operations can be carried out as usual. In this manner, the exclusive control is realized without requiring the programmer to program the lock explicitly. See, E. Shekita et al.: "Cricket: A Mapped, Persistent Object Store", Proc. of the 4th Intl. Workshop on Persistent Object Systems Design, Implimentation and Use, pp. 89-102, September 1990, for further detail.
Now, this automatic locking scheme is not applicable to the program for the multi-threading, because in the multi-threading, the virtual space is shared by the threads so that the change of the page protection mode by one thread is also reflected in the other threads as well. Namely, as shown in FIG. 1, in the multi-threading environment for a process 5 using a plurality of threads 50 and a virtual space 30, the shared data 20 of the secondary memory 2 are going to be mapped into the shared data mapping region 300 in the virtual space 30 which is common to all the threads 50. In such a case, the data updated by one thread can be read or updated by the other threads before the lock is released by that one thread, for example. Consequently, in order to automate the exclusive control in the multi-threading, it is necessary to carry out the locking operation whenever there is an access to the shared data. Yet, this locking operation deals with the lock which is the shared resource, so that it must be carried out in the critical section which can be executed by only one thread. Thus, when the locking operation is carried out for each access in this manner, the extra processing is going to be required for each access to the shared data, so that the performance of the program can be lowered considerably and the parallelism of the threads can also be lowered.
As described, the program for manipulating the shared data by the multi-threading has been associated with the problem that the lock must be programmed explicitly so that the programming becomes complicated, or that the exclusive control must be carried out for each access, so that it is impossible to take a full advantage of the high performance supported by the multi-threading. Of these, the former problem gives rise to a further problem that the programs executable by the conventional single thread cannot be used as they are in the multi-threading environment so that there arises a need to rewrite all such programs. On the other hand, the latter problem gives rise to a further problem that the parallelism of the threads is going to be lowered as the access to the shared data must be made in the critical section of the thread.